package service

import (
	"context"
	__ "user_service/basic/proto"
	"user_service/handler/model"
)

// 商品展示
func (s *Server) GoodList(_ context.Context, in *__.GoodListReq) (*__.GoodListResp, error) {

	var good model.Good
	goodList, err := good.List()
	if err != nil {
		panic(err)
	}
	var goodLists []*__.GoodList
	for _, g := range goodList {
		list := __.GoodList{
			Id:    int64(g.Id),
			Name:  g.Name,
			Info:  g.Info,
			Stock: int64(g.Stock),
			Price: float32(g.Price),
		}
		goodLists = append(goodLists, &list)
	}

	return &__.GoodListResp{
		List: goodLists,
	}, nil
}
